<?php

namespace app\admin\logic;
use think\Model;
class Crud extends Model{
     public function SaveData($Data){
        $table = $Data["table"];
        //删除table项
        unset($Data['table']);
        
        if (!!trim($Data["id"])) {
              \think\Db::table($table)->update($Data);
              $ret_arr = \think\Db::table($table)->where('id',$Data['id'])->select(); 
              $ret = $ret_arr[0];
              
        }else{
              $id = \think\Db::table($table)->insertGetId($Data);
              $ret = array(
                  'id' => $id
              );
        }
        return $ret;
    }
    
      public function delPic($productID){
       $list = \app\admin\model\Picture::where('productId',$productID)->delete();
//        \think\Db::table('picture')->where('productsID',$productID)->delete();
    }
    
}